package com.example.javaui.slice;

import com.example.javaui.ResourceTable;
import com.example.javaui.slice.component.*;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class ComponentAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_component);

        Button btnText = (Button) findComponentById(ResourceTable.Id_btn_text);
        btnText.setClickedListener((Component component) -> {
            present(new TextSlice(), new Intent());
        });

        Button btnButton = (Button) findComponentById(ResourceTable.Id_btn_button);
        btnButton.setClickedListener((Component component) -> {
            present(new ButtonSlice(), new Intent());
        });

        Button btnProgressBar = (Button) findComponentById(ResourceTable.Id_btn_progressbar);
        btnProgressBar.setClickedListener((Component component) -> {
            present(new ProgressBarSlice(), new Intent());
        });

        Button btnImage = (Button) findComponentById(ResourceTable.Id_btn_image);
        btnImage.setClickedListener((Component component) -> {
            present(new ImageSlice(), new Intent());
        });

        Button btnPicker = (Button) findComponentById(ResourceTable.Id_btn_picker);
        btnPicker.setClickedListener((Component component) -> {
            present(new PickerSlice(), new Intent());
        });

        Button btnComponentState = (Button) findComponentById(ResourceTable.Id_btn_component_state);
        btnComponentState.setClickedListener((Component component) -> {
            present(new ComponentStateSlice(), new Intent());
        });

        Button btnCustomComponent = (Button) findComponentById(ResourceTable.Id_btn_component_custom);
        btnCustomComponent.setClickedListener((Component component) -> {
            present(new CustomComponentSlice(), new Intent());
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
